package com.woniu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniu.entity.dto.QueryInspectorDTO;
import com.woniu.entity.vo.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.pojo.Inspector;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import com.woniu.pojo.Order;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;

/**
* @author Ma.Lei
* @description 针对表【t_inspector】的数据库操作Mapper
* @createDate 2022-12-16 23:27:45
* @Entity generator.domain.Inspector
*/
public interface InspectorMapper extends BaseMapper<Inspector> {
    Page<InspectorParkingRecordsVo> findParkingRecords(IPage page,@Param("id") String inspectorId, @Param("st") Date startTime,@Param("et") Date endTime);

    Page<InspectorBerthRecordsVo> findBerthRecords(IPage page, @Param("id")String inspectorId, @Param("rn")String roadName);

    @Update("update t_inspector set `status` = #{status} where `id` = #{id};")
    int disabledInspector(String id, Integer status);

    List<QueryInspectorVO> listInspector(@Param("queryInspectorDTO") QueryInspectorDTO queryInspectorDTO);

    QueryInspectorVO listSearchById(@Param("id") String id);

    List<QueryRoadVO> selectRoadById(String id);

    @Select("select o.id,o.order_code,r.road_name,c.car_number,o.price,o.order_status\n" +
            "\tfrom t_order o,t_car c,t_road r\n" +
            "\twhere o.car_id = c.id\n" +
            "\tand o.road_id = r.id\n" +
            "\tand o.is_deleted = 0\n" +
            "\tand o.inspector_id = #{id};")
    List<QueryOrderByInspectorIdVO> QueryOrderByInspectorIdVO(String id);
    @Select("select * from t_order where order_status = '2' and car_id = #{carId}")
    Order getOrder(String carId);

    String getOrderStatusByCarNum(String carNum);


    int roadInsertInspectorId(@Param("roadId") String roadId,@Param("id") String id);

    @Select("select id,inspector_name,inspector_phone,password,status\n" +
            "from t_inspector\n" +
            "where id = #{id}")
    QueryAddAndUpdeteInspectorVO listInspectorById(String id);

    InspectorDetailedStatisticsVO inspectorDetailedStatisticsById(@Param("id") String id);

    void deleteRoadInspector(String id);
}




